// API 接口配置
export interface ApiResponse<T = any> {
  code: number
  message: string
  data: T
  success: boolean
}

// 请求配置接口
export interface RequestConfig {
  url: string
  method: 'GET' | 'POST' | 'PUT' | 'DELETE'
  data?: any
  header?: Record<string, string>
  timeout?: number
  showLoading?: boolean
  loadingText?: string
}

// API 基础配置
export const API_CONFIG = {
  // 请求超时时间
  timeout: 60000,

  // 默认请求头
  defaultHeaders: {
    'Content-Type': 'application/json; charset=UTF-8',
    'Accept': 'application/json'
  },

  // 状态码配置
  statusCode: {
    SUCCESS: 200,
    UNAUTHORIZED: 401,
    FORBIDDEN: 403,
    NOT_FOUND: 404,
    SERVER_ERROR: 500
  },

  // 错误消息配置
  errorMessages: {
    NETWORK_ERROR: '网络连接失败，请检查网络设置',
    TIMEOUT_ERROR: '请求超时，请稍后重试',
    SERVER_ERROR: '服务器错误，请稍后重试',
    UNAUTHORIZED: '登录已过期，请重新登录',
    FORBIDDEN: '没有权限访问该资源',
    NOT_FOUND: '请求的资源不存在'
  }
}

// API 接口地址配置
export const API_ENDPOINTS = {
  // 认证相关
  AUTH: {
    LOGIN: '/auth/login',//登陆
    WECHAT_LOGIN: '/auth/wechat',
    LOGIN_WITH_CODE: '/auth/login-code',
    SEND_CODE: '/auth/send-code',
    REGISTER: '/auth/register',
    RESET_PASSWORD: '/auth/reset-password',
    REFRESH_TOKEN: '/auth/refresh-token',
    LOGOUT: '/auth/logout'
  },

  // 用户相关
  USER: {
    INFO: '/auth/info',                    // 获取当前用户信息 - 根据JWT token解析用户信息
    UPDATE: '/user/update',                // 更新用户信息
    AVATAR: '/user/avatar',                // 上传/更新用户头像
    CHANGE_PASSWORD: '/user/change-password' // 修改密码
  },

  // 待办事项
  TODO: {
    LIST: '/todo/list',
    HANDLE: '/todo/handle',
    DETAIL: '/todo/detail'
  },

  // 文档相关
  DOCUMENT: {
    RECENT: '/document/recent',
    LIST: '/document/list',
    DETAIL: '/document/detail',
    UPLOAD: '/document/upload',
    DOWNLOAD: '/document/download'
  },

  // 公告相关
  ANNOUNCEMENT: {
    LIST: '/announcement/list',
    DETAIL: '/announcement/detail'
  },

  // 文件上传
  UPLOAD: {
    IMAGE: '/upload/image',
    FILE: '/upload/file',
    AVATAR: '/upload/avatar'
  }
}
